package com.jingtai.platform.controller.shop;

import com.jingtai.core.entity.BaseEntity;
import com.jingtai.core.entity.shop.GoodsCategory;
import com.jingtai.platform.service.shop.GoodsCategoryService;
import com.jingtai.platform.util.ResultUtil;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.jingtai.validate.swagger.CApiParam;

/**
 * 商品分类表
 *
 * @author sunlaiqian
 * @date 2020-12-02 18:31:33
 */
@Validated
@RestController
@RequestMapping("/platform/goodscategory")
@Api(tags = "商品分类表")
public class GoodsCategoryController{

    @Autowired
    private GoodsCategoryService goodsCategoryService;


    @ApiOperation("商品分类表列表查询")
    @GetMapping("/list")
    public ResultUtil aopGoodsCategoryList(@CApiParam(name = "page",value = "页数",required = true,cNotEmpty = true,cIntMin = 1) @RequestParam("page") Integer page,
                              @CApiParam(name = "limit",value = "每页个数",required = true,cNotEmpty = true,cIntMin = 1) @RequestParam("limit") Integer limit,
                              @CApiParam(name = "conditions",value = "查询条件",required = false) @RequestParam("conditions") String conditions){
        return goodsCategoryService.GoodsCategorylist(page, limit, conditions);
    }


    @ApiOperation("根据ID查询goodsCategory实体")
    @GetMapping("/getGoodsCategoryById")
    public ResultUtil GetGoodsCategoryById(@CApiParam(name = "id",value = "goodsCategory实体ID",required = true,cNotEmpty = true) @RequestParam("id") Long id){
        return goodsCategoryService.getGoodsCategoryById(id);
    }


    @ApiOperation("新增goodsCategory实体")
    @PostMapping("/add")
    @ApiOperationSupport(ignoreParameters = {"goodsCategory.id","goodsCategory.createTime","goodsCategory.updateTime","goodsCategory.deleteFlag"})
    public ResultUtil aopAddGoodsCategory(@RequestBody @Validated({BaseEntity.Create.class}) GoodsCategory goodsCategory){
        return goodsCategoryService.addGoodsCategory(goodsCategory);
    }

    @ApiOperation("编辑goodsCategory实体")
    @PostMapping("/edit")
    @ApiOperationSupport(ignoreParameters = {"goodsCategory.createTime","goodsCategory.updateTime","goodsCategory.deleteFlag"})
    public ResultUtil aopEditGoodsCategory(@RequestBody @Validated({BaseEntity.Update.class}) GoodsCategory goodsCategory){
        return goodsCategoryService.editGoodsCategory(goodsCategory);
    }

    @ApiOperation("根据ID删除goodsCategory实体")
    @GetMapping("/delGoodsCategoryById")
    public ResultUtil aopDelGoodsCategoryById(@CApiParam(name = "id",value = "goodsCategory实体ID",required = true,cNotEmpty = true) @RequestParam("id") Long id){
        return goodsCategoryService.delGoodsCategoryById(id);
    }


    @ApiOperation("查询可用的商品分类")
    @GetMapping("/selectAllCategory")
    public ResultUtil aopSelectAllCategory(){
        return goodsCategoryService.selectAllCategory();
    }

    @ApiOperation("查询一级分类")
    @GetMapping("/selectGoodsCategoryOfOne")
    public ResultUtil aopSelectGoodsCategoryOfOne(){
        return goodsCategoryService.selectGoodsCategoryOfOne();
    }

    @ApiOperation("根据一级分类查询二级分类")
    @GetMapping("/selectGoodsCategoryOfTwoById")
    public ResultUtil aopSelectGoodsCategoryOfTwoById(@CApiParam(name = "id",value = "goodsCategory实体一级ID",required = true,cNotEmpty = true) @RequestParam("id") Long id){
        return goodsCategoryService.selectGoodsCategoryOfTwoById(id);
    }

}






